<template>
  <div class="">
    <ul>
      <li class="list" v-for="(item, index) in $store.state.list" :key="index">
        <input
          type="checkbox"
          v-model="$store.state.result"
          :value="item"
          @change="change"
        />
        <span>{{ item.title }}</span>
        <button @click="remove(index, item)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  created() {},
  methods: {
    remove(index, item) {
      this.$store.commit("remove", { index, item });
    },
    change() {
      this.$store.commit("change");
    },
  },
  components: {},
};
</script>

<style lang="scss" scoped>
.list {
  button {
    display: none;
  }
}
.list:hover {
  background: #ccc;
  button {
    display: inline-block;
  }
}
</style>
